"use strict";
cc._RF.push(module, 'a27447LHA5Kz6caGFilUah5', 'infinitypower');
// scripts/res/infinitypower.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../engines/gameEngine");
var userInterface_1 = require("../engines/services/userContent/userInterface");
var gameConfig_1 = require("../engines/configs/gameConfig");
var data_control_1 = require("../engines/libs/data_control");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var InfinityPower = /** @class */ (function (_super) {
    __extends(InfinityPower, _super);
    function InfinityPower() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.detail = null;
        _this.looktimeLabel = null;
        _this.lbMessageExplain = null;
        _this.showInfoLabel = null;
        _this.RewardView = null;
        _this.Reward = null;
        return _this;
        // update (dt) {}
    }
    InfinityPower_1 = InfinityPower;
    InfinityPower.prototype.onLoad = function () {
        this.UpdateLookLabel();
        this.node.zIndex = cc.macro.MAX_ZINDEX;
    };
    InfinityPower.prototype.start = function () {
        gameEngine_1.modules().uiControlModule.showHideDialogAnimation(this.detail, true);
        this.showInfoLabel.string = "\u6B23\u8D4F" + gameConfig_1.default.INFINTY_VIDEO_TIME + "\u6B21\u89C6\u9891\u83B7\u53D6" + data_control_1.default.MinusToHours(gameConfig_1.default.INFINITY_POWER_VIDEO_HAND_TIME) + "\u65E0\u9650\u4F53\u529B"; //this.lbMessageExplain.string.replace(/#/g, `${gameConfig.INFINITY_POWER_VIDEO_COUNT}`);
    };
    InfinityPower.prototype.OnNoLookBtn = function () {
        gameEngine_1.default.getManagers().soundMgr.playSound('mainSound/anNiu').then();
        this.onClose();
    };
    InfinityPower.prototype.OnLookBtn = function () {
        var _this = this;
        gameEngine_1.default.getManagers().soundMgr.playSound('mainSound/anNiu').then();
        if (InfinityPower_1.lookedTimes < gameConfig_1.default.INFINTY_VIDEO_TIME) {
            gameEngine_1.default.getServices().miniGameSrv.getAppApiInstance().loadAndShowVideoAd(function () {
                InfinityPower_1.lookedTimes++;
                _this.UpdateLookLabel();
                if (InfinityPower_1.lookedTimes == gameConfig_1.default.INFINTY_VIDEO_TIME) {
                    //进入无限体力模式
                    gameEngine_1.default.getServices().userSrv.setPower(999, true, true);
                    // O1HD.getServices().localStorageSrv.setStorage(this.InfinityModel, 1)
                    gameEngine_1.default.getModules().uiControlModule.showGetRewarded(userInterface_1.REWARD_TYPE.POWER, 999, '获得体力');
                    _this.onClose();
                }
            }, function () {
            }, null, '解锁无限体力');
        }
    };
    InfinityPower.prototype.onClose = function () {
        var _this = this;
        gameEngine_1.modules().uiControlModule.showHideDialogAnimation(this.detail, false, function () {
            _this.node.destroy();
        });
    };
    InfinityPower.prototype.UpdateLookLabel = function () {
        if (this.looktimeLabel) {
            this.looktimeLabel.string = "(" + InfinityPower_1.lookedTimes.toString() + "/" + gameConfig_1.default.INFINTY_VIDEO_TIME + ")";
        }
    };
    var InfinityPower_1;
    // LIFE-CYCLE CALLBACKS:
    InfinityPower.lookedTimes = 0;
    __decorate([
        property(cc.Node)
    ], InfinityPower.prototype, "detail", void 0);
    __decorate([
        property(cc.Label)
    ], InfinityPower.prototype, "looktimeLabel", void 0);
    __decorate([
        property(cc.Label)
    ], InfinityPower.prototype, "lbMessageExplain", void 0);
    __decorate([
        property({ type: cc.Label, displayName: "获取信息展示" })
    ], InfinityPower.prototype, "showInfoLabel", void 0);
    __decorate([
        property(cc.Prefab)
    ], InfinityPower.prototype, "RewardView", void 0);
    __decorate([
        property(cc.Node)
    ], InfinityPower.prototype, "Reward", void 0);
    InfinityPower = InfinityPower_1 = __decorate([
        ccclass
    ], InfinityPower);
    return InfinityPower;
}(cc.Component));
exports.default = InfinityPower;

cc._RF.pop();